home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / swtools / trubasic / rolldemos / demos / interact / record.tru < prev    next >
Text File  |  1994-08-02  |  2KB  |  100 lines

  1. !
  2. !  RECORD     version 2.0
  3. !
  4. !  Record a series of perspective images of the house.
  5. !  Replays them to animate the house spinning.
  6. !
  7. !  Note that for X Windows BOX KEEP strings contain ids for pixmaps which
  8. !  exist only when the program is running.  Therefore we can not write
  9. !  the images out to a file, CHAIN to another program, and redisplay them
  10. !  using BOX SHOW.
  11. !
  12. LIBRARY "../3d/3dlib.trc"
  13. call tw_wset_title(0,"record")
  14.  
  15. OPEN #1: screen .25,.7,.25,.7
  16. CALL PersWindow(0,1,0,1,0,1)
  17. DIM image$(1)
  18.  
  19. LET frames = 30
  20. MAT image$ = Nul$(frames)
  21.  
  22. FOR i = 1 to frames
  23.     CLEAR
  24.     LET u = 2*pi*i/frames
  25.     LET x = 2*sin(u) + .5
  26.     LET y = 2*cos(u) + .5
  27.     LET z = 2*sin(u) + .5
  28.     CALL SetCamera3(x,y,z)
  29.     CALL DrawHouse
  30.     ASK WINDOW x1,x2,y1,y2
  31.     BOX KEEP x1,x2,y1,y2 in image$(i)
  32. NEXT i
  33.  
  34. CALL playback(image$,frames)
  35.  
  36. END
  37.  
  38. !
  39. !  DrawHouse
  40. !
  41. !  A slightly complicated 'house' picture, which draws
  42. !  an opaque floor.  If we're looking at the house from
  43. !  above, we must draw the floor first.  From below, we
  44. !  we must draw the floor last.
  45. !
  46. SUB DrawHouse
  47.     DIM house(12,3)
  48.  
  49.     CALL AskCamera3(x,y,z)
  50.     IF z>0 then CALL Floor
  51.  
  52.     MAT READ house
  53.     PLOT
  54.     CALL MatLines3(house)
  55.  
  56.     CALL LineOff3(1,0,.5, 0,0,.5)      !parts of roofline
  57.     CALL LineOff3(1,1,.5, 0,1,.5)
  58.     CALL LineOff3(1,1,0,  0,1, 0)
  59.     CALL LineOff3(1,.5,1, 0,.5,1)
  60.  
  61.     DATA 0,0,0, 0,0,.5, 0,.5,1, 0,1,.5, 0,1,0, 0,0,0
  62.     DATA 1,0,0, 1,0,.5, 1,.5,1, 1,1,.5, 1,1,0, 1,0,0
  63.  
  64.     CALL RectX3(0,.2,.4,.2,.4)    !windows
  65.     CALL RectX3(0,.6,.8,.2,.4)
  66.  
  67.     CALL RectY3(0,.45,.55,0,.4)   !front door
  68.  
  69.     CALL RectX3(1,.3,.7,.15,.4)   !big picture window
  70.  
  71.     CALL CircleY3(1,.3,.4,.1,.4)  !weird circular windows
  72.     CALL CircleY3(1,.6,.7,.1,.4)
  73.  
  74.     IF z<0 then CALL Floor
  75.  
  76. END SUB
  77.  
  78. SUB Floor
  79.     SET COLOR "red"
  80.     CALL FillRectZ3(0,0,1,0,1)
  81.     SET COLOR "yellow"
  82. END SUB
  83.  
  84. SUB playback(image$(),frames)
  85.  
  86. !
  87. !  Loop displaying frames from array.
  88. !
  89. let i=0
  90. window #0
  91. for n=1 to 100
  92.    LET i = i+1
  93.    IF i>frames then LET i=1
  94.    BOX SHOW image$(i) at .25,.25 
  95.    PAUSE .04
  96.    get mouse x,y,state
  97.    if state<>0 then stop
  98. next n
  99. END SUB
  100.